<!DOCTYPE html>
<html>
{include file="Login/header" /}
<style>
    img{width: 200px}
    span{color: #cc181b}
</style>
<body class="login" mycollectionplug="bind" style="background: #44AAFF">
<div class="reg_boder reg_boder_company">
    <div class="reg_m" >
        <div class="reg_title">
        <div style="font-size: 26px;    ">注册企业商户</div>
        </div>
    <form action="{:url('index/doRegister')}" id="regFrom" method="post">
        <input type="hidden" name="user_type" value="2">
        <h2><span>*</span>邮箱：</h2>
        <label>
            <input type="email" name="email" class="txt_input txt_input2" required  value="" placeholder="">
        </label>
        <h2><span>*</span>手机号：</h2>
        <label>
            <input type="text" name="phone" class="txt_input txt_input2" required  value="" placeholder="">
        </label>
        <h2><span>*</span>密码：</h2>
        <label>
            <input type="password" name="password" class="txt_input txt_input2" required  value="" placeholder="不能低于6位">
        </label>
        <h2><span>*</span>确认密码：</h2>
        <label>
        <input type="password" name="password2" class="txt_input txt_input2" required  value="" placeholder="">
        </label>

        <label>
            <div class="col-sm-12 text-center" style="width: 300px;margin: 0 auto;">

                <button type="button" id="submit" class="btn btn-success">提交</button>
            </div>
        </label>
    </form>
</div>

</body>
{include file="Login/footer" /}

<script>

    $(document).ready(function(){
        $("#submit").click(function(){

            if($("input[name='password']").val().length<6)
            {
                alert('账户密码不得少于6位');
                $(this).val('');
                return false;
            }

            if($("input[name='password2']").val()!== $("input[name='password']").val())
            {
                alert('两次密码不一致');
                $(this).val('');
                return false;
            }

            var email=$("input[name='email']");
            if(email.val()=="")
            {
                alert("邮箱不能为空");
                return false;
            }

            if(!email.val().match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/))
            {
                alert("格式不正确！请重新输入");
                email.focus();
                return false;
            }

            var phone = $("input[name='phone']");
            var flag = false;
            var message = "";
            var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if(phone.val().length !=11){
                message = "请输入有效的手机号码！";
            }else if(!myreg.test(phone.val())){
                message = "请输入有效的手机号码！";
            }else{
                flag = true;
            }
            if(!flag){
                phone.val('');
                phone.focus();
                alert(message);
                return false;
            }

            var data = $("#regFrom").serialize();
            toAjax("{:url('index/doRegister')}",
                data,"GET",
                function(rs){
                    console.log(rs);

                    if(rs.code == 1){
                        console.log(rs.message);
                        if(rs.data.url != null){
                            window.location = rs.data.url;
                        }
                        else{
                            alert(rs.message);
                            //history.go(0);
                        }
                    }

                    if(rs.code == 0){
                        window.location = rs.data.url;
                    }
                },
                false,false,this);

        });

    });


</script>
